package com.tjp.eight.ui.fragment.search;

import com.tjp.eight.AllRetrofit;
import com.tjp.eight.base.BasePresenterImpl;
import com.tjp.eight.constant.UrlConstant;
import com.tjp.eight.net.NetCallBack;
import com.tjp.eight.net.SubscribeCallBack;
import com.tjp.eight.ui.fragment.tabFind.FindResultModel;
import com.tjp.eight.utils.AppUtils;

import okhttp3.RequestBody;

/**
 * Created by Administrator on 2017/2/27.
 */
public class SearchPresenter extends BasePresenterImpl<SearchsView>{
    SearchService service = AllRetrofit.getRetrofit(UrlConstant.BaseUrl).create(SearchService.class);
    public SearchPresenter(SearchsView view){
        attachView(view);
    }
    public void loadData(String pjson) {
        RequestBody body = AppUtils.getRequestBody(pjson);
        addSubscription(service.loadData(body), new SubscribeCallBack<>(new NetCallBack<FindResultModel>() {
            @Override
            public void onSuccess(FindResultModel model) {
                view.loadsuccess(model);
            }

            @Override
            public void onFails(int code, String msg) {
                view.loadfail(msg);
            }

            @Override
            public void onCompleted() {

            }
        }));
    }
}
